-module(test_mapreduce).
-compile(export_all).

test() ->
    F1 = fun generate_words/2,
    F2 = fun count_words/3,
    Words = ["hello", "jordan", "hello", "pipen"],
    L1 = phofs:mapreduce(F1, F2, [], Words),
    lists:reverse(lists:sort(L1)).

generate_words(Pid, Word) ->
    Pid ! {list_to_atom(Word), 1}.

count_words(Key, Vals, A) ->
    [{length(Vals), Key}|A].
